package com.czy.owner.ui.business;


import android.widget.TextView;
import com.czy.owner.R;
import com.czy.owner.api.ScopeBusinessDetailApi;
import com.czy.owner.db.UserHelper;
import com.czy.owner.entity.ScopeBusinessDetailModel;
import com.czy.owner.global.Constants;
import com.czy.owner.net.http.HttpManager;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.czy.owner.ui.BaseActivity;
import com.czy.owner.utils.PhoneUtils;
import com.czy.owner.utils.SharedPreferencesUtils;

import butterknife.BindView;

/**
 * Created by wangyang on 2016/7/7 0007.
 * 业务范围详情
 */
public class ScopeBusinessDetailActivity extends BaseActivity {
    @BindView(R.id.tv_servicename)
    TextView tvServiceName;
    @BindView(R.id.tv_servicename_description)
    TextView tvServiceNameDescription;
    private int storeServiceId=0;
    private String serviceName="title";
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_scopebusiness_detail;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {
        serviceName = getIntent().getStringExtra("serviceName");
        storeServiceId = getIntent().getIntExtra("storeServiceId",0);
        getToolbarTitle().setText(serviceName);
        tvServiceName.setText(serviceName);
        showDetail();
    }

    @Override
    protected void updateViews() {

    }



    private void showDetail(){
        ScopeBusinessDetailApi scopeBusinessDetailApi = new ScopeBusinessDetailApi(new HttpOnNextListener<ScopeBusinessDetailModel>() {
            @Override
            public void onNext(ScopeBusinessDetailModel model) {
                String description = model.getDescription();
                tvServiceNameDescription.setText(description);
            }

            @Override
            public void onCacheNext(String string) {
                super.onCacheNext(string);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                PhoneUtils.ShowToastMessage(ScopeBusinessDetailActivity.this,e.getMessage());
            }
        },this);
        scopeBusinessDetailApi.setSession(UserHelper.getInstance().getSessionInfoModel(this).getSession());
        scopeBusinessDetailApi.setStoreId(SharedPreferencesUtils.getParam(ScopeBusinessDetailActivity.this, UserHelper.getInstance().getUserAccount()+ Constants.SHARED_PREFERENCES_KEY_BINDSTOREID,0)+"");
        scopeBusinessDetailApi.setStoreServiceId(storeServiceId+"");
        HttpManager httpManager = HttpManager.getInstance();
        httpManager.doHttpDeal(scopeBusinessDetailApi);
    }



}
